use "C:\Users\ibo6\OneDrive - The Pennsylvania State University\Working Papers\Target Hardening\v10 Terrorism and Political Violence\R & R\Analysis\rdyads2.dta", replace


* Selection criteria 
generate s = total > 0 

* logged version of the number of police stations
gen sta_intel_log = log(sta_intel + 1)

* TABLE 3A
** Model 13: Soft Targets (simple)
heckman softtot sta_intel_log a_l suictot_l, select(s = battal_log_l a_l pop_log) vce(cluster dyadid)
estimates store t5_soft_simple
** Model 14: Soft Targets (extended)
heckman softtot sta_intel_log a_l suictot_l coin_deaths_log_l inten epr ib2.ideology, select(s = battal_log_l a_l coin_deaths_log_l pop_log) vce(cluster dyadid)
estimates store t5_soft_extended
** Model 15: Civilian Targets Only (extended)
heckman civitot sta_intel_log a_l suictot_l coin_deaths_log_l inten epr ib2.ideology, select(s = battal_log_l a_l coin_deaths_log_l pop_log) vce(cluster dyadid)
estimates store t5_civi_extended
** Model 16: Hard Targets (extended)
heckman hardtot sta_intel_log a_l suictot_l coin_deaths_log_l inten epr ib2.ideology, select(s = battal_log_l a_l coin_deaths_log_l pop_log) vce(cluster dyadid)
estimates store t5_hard_extended
** Model 17: Mlitary Targets Only (extended)
heckman militot sta_intel_log a_l suictot_l coin_deaths_log_l inten epr ib2.ideology, select(s = battal_log_l a_l coin_deaths_log_l pop_log) vce(cluster dyadid)
estimates store t5_mili_extended

ssc install estout
label variable sta_intel_log "Hardening (Alternative measure)"
label variable a_l "Success rate against hard targets (lagged)"
label variable suictot_l "Ratio of suicide attacks (lagged)"
label variable coin_deaths_log_l "COIN casualties (lagged)"
label variable inten "Conflict intensity"
label variable epr "Ethnic fractionalization"
label variable ideology "Group ideology"
label variable pop_log "State population"

esttab t5_soft_simple t5_soft_extended t5_civi_extended t5_hard_extended t5_mili_extended using apptable3A.csv, b(%5.3f) mlabel("Soft" "Soft" "Civilian" "Hard" "Military") se starlevels(* 0.1 ** 0.05 *** 0.01) label noconstant title("Heckman Selection Models of Target Selection in Relevant State-Group Dyads in India, 2004-2016") addnotes("Heckman Selection Models are estimated using full maximum likelihood with Stata's heckman command. The bottom half of the table presents estimations of the selection equation. The selection criteria is whether or not a given relevant state-group dyad experienced at least 1 insurgent attack in a given year. The upper half of the table presents estimations of prevalence of attacks against respective target types. The dependent variables are the ratio of number of attacks against respective target types to total number of attacks committed in a given relevant state-group dyad in a given year. Robust standard errors clustered on relevant state-group dyads are presented in parantheses.")





* TABLE 4A
** Model 18: Interaction of hardening and ideology
heckman softtot c.sta_intel_log_l##ib2.ideology a_l suictot_l coin_deaths_log_l inten epr, select(s = sta_intel_log_l a_l coin_deaths_log_l pop_log) vce(cluster dyadid)
estimates store t6_hardening_ideology
** Model 19: Interaction of success rate against hard targets and ideology
heckman softtot sta_intel_log_l c.a_l##ib2.ideology suictot_l coin_deaths_log_l inten epr, select(s = sta_intel_log_l a_l coin_deaths_log_l pop_log) vce(cluster dyadid)
estimates store t6_success_ideology


label define ideology 1 "Ethnonationalist" 2 "Religious" 3 "Leftist" 4 "Other"
label values ideology ideology

esttab t6_hardening_ideology t6_success_ideology using apptable4A.csv, b(%5.3f) mlabel("Soft" "Soft" "Soft" "Soft") se starlevels(* 0.1 ** 0.05 *** 0.01) label noconstant nobaselevels title("Heckman Selection Models of Target Selection in Relevant State-Group Dyads in India, 2004-2016") addnotes("Heckman Selection Models are estimated using full maximum likelihood with Stata's heckman command. The bottom half of the table presents estimations of the selection equation. The selection criteria is whether or not a given relevant state-group dyad experienced at least 1 insurgent attack in a given year. The upper half of the table presents estimations of prevalence of attacks against respective target types. The dependent variables are the ratio of number of attacks against respective target types to total number of attacks committed in a given relevant state-group dyad in a given year. Robust standard errors clustered on relevant state-group dyads are presented in parantheses. The reference category for the Group ideology variable is religious-fundementalist groups. Maoist insurgency is coded 1 for every relevant-state group dyad that includes one of the following states: West Bengal, Bihar, Andhra Pradesh, Chhattisgarh, Jharkhand and Odisha. Northeast insurgencies is coded 1 for every relevant-state group dyad that includes one of the following states: Assam, Manipur, Mizoram, Nagaland, Tripura, Arunachal Pradesh and Sikkim.")



